package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.pojo.FamilyInfo;
import com.example.pojo.dto.UserParentInfoDTO;
import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface FamilyMapper extends MPJBaseMapper<FamilyInfo>, BaseMapper<FamilyInfo> {
    @Select("\n" +
            "SELECT\n" +
            "    s.id AS id,\n" +
            "    s.name AS studentName,\n" +
            "    s.gender,\n" +
            "    s.stu_avatar,\n" +
            "    s.birth_date,\n" +
            "    s.emergency_contact_name AS parentName,\n" +
            "    s.emergency_contact_phone AS parentPhone,\n" +
            "    s.current_address,\n" +
            "    s.class_id AS classId,\n" +
            "    s.class_grade_level,\n" +
            "    s.class_teacher_id,\n" +
            "    s.bind_code\n" +
            "FROM\n" +
            "    stu_info s\n" +
            "WHERE\n" +
            "    s.name = #{stuName}")
    UserParentInfoDTO selectFamilyByStuName(@Param("stuName") String stuName);

    @Select("SELECT id FROM stu_info")
    List<Long> selectAllParentIds();
}